home *** CD-ROM | disk | FTP | other *** search
/ Games of Daze / Infomagic - Games of Daze (Summer 1995) (Disc 1 of 2).iso / x2ftp / msdos / libs / knowhow4 / mkicon.cpp < prev    next >
C/C++ Source or Header  |  1994-10-10  |  3KB  |  97 lines

  1. #include <alloc.h>      // This program shows pcx file on the screen
  2. #include <iostream.h>   // You can use any other library to show pictures of
  3. #include <graphics.h>   // another format - it will not change format of
  4. #include <stdlib.h>     // icont you obtian. Icons are images, written to
  5. #include <stdio.h>      // the file CGA.RES, EGA.RES ... (depending of mode).
  6. #include <conio.h>      // Size of icons is ICON_X to ICON_Y
  7.             // Name of pcx file is CGA.PCX, EGA.PCX and so on.
  8. #include "event.h"
  9. #include "pcx.h"
  10. #include "geom.h"
  11. #include "item.h"
  12. #include "colors.h"
  13. #include "icon.h"
  14. #include "ic_part.h"
  15.  
  16. //////////////////////////////
  17. void main()
  18.     {
  19.     int gdriver, scr, type;
  20.     cout << "█████████████\n";
  21.     cout << "█ VGA......1█\n";
  22.     cout << "█ EGA......2█\n";
  23.     cout << "█████████████\n";
  24.     cin >> scr;
  25.     switch(scr)
  26.     {
  27.     case 1: gdriver = VGA; break;
  28.     case 2: gdriver = EGA; break;
  29.         default: return;
  30.     }
  31.  
  32.     cout << "Icon type 1 - 2 - 3 (middle - small - large) ";
  33.     cin >> type;
  34.  
  35.     if(!init_KNOW_HOW(gdriver))
  36.         return;
  37.  
  38.     char* fName;
  39.     char* resName;
  40.     switch(gdriver)
  41.     {
  42.         case      EGA:
  43.         switch(type)
  44.         {
  45.         case 1: fName = "egahi1.pcx"; resName = "egahi1.res"; break;
  46.         case 2: fName = "egahi2.pcx"; resName = "egahi2.res"; break;
  47.         case 3: fName = "egahi3.pcx"; resName = "egahi3.res"; break;
  48.                 default: return;
  49.         }
  50.         break;
  51.         case      VGA:
  52.         switch(type)
  53.         {
  54.         case 1: fName = "vgahi1.pcx"; resName = "vgahi1.res"; break;
  55.         case 2: fName = "vgahi2.pcx"; resName = "vgahi2.res"; break;
  56.         case 3: fName = "vgahi3.pcx"; resName = "vgahi3.res"; break;
  57.                 default: return;
  58.         }
  59.         break;
  60.       default:
  61.       fprintf(stderr, "wrong monitor type !!!\n");
  62.       exit(1);
  63.       }
  64.     pcx_file_scr(fName, loc(0, 0));
  65.  
  66.     Item item;
  67.     event e;
  68.     int x = 0;
  69.     int y = 0;
  70.  
  71.     loc size = icon_size(type);
  72.     while(e.key != EVENT_ESC)
  73.     {
  74.     item.show(rect(x, y, x + size.X, y + size.Y));
  75.     e = getevent(KEYEVENT);
  76.     item.hide(rect(x, y, x + size.X, y + size.Y));
  77.     switch(e.key)
  78.         {
  79.         case EVENT_ESC: break;
  80.         case EVENT_LEFT: x = x > 0 ? x - 1 : x; break;
  81.         case EVENT_RIGHT: x = x < getmaxx() ? x + 1 : x; break;
  82.         case EVENT_UP: y = y > 0 ? y - 1 : y; break;
  83.         case EVENT_DN: y = y < getmaxy() ? y + 1 : y; break;
  84.         case EVENT_HOME: x = x > 10 ? x - 10 : x; break;
  85.         case EVENT_END: x = x < getmaxx() - 10 ? x + 10 : x; break;
  86.         case EVENT_PG_UP: y = y > 10 ? y - 10 : y; break;
  87.         case EVENT_PG_DN: y = y < getmaxy() - 10 ? y + 10 : y; break;
  88.         case EVENT_RETURN: save_image(resName, loc(x, y), type); break;
  89.         }
  90.     }
  91.  
  92.     close_KNOW_HOW();
  93.     closegraph();
  94.  
  95.     }
  96.  
  97.